package cn.kgc.reflect;

/**
 * @author: mosin
 * @version: v1.0  2022/10/20
 * 通过反射获取类的相关信息
 */
public class ReflectDemo02 {

    public static void main(String[] args) {

        try {

            Class  clazz = Class.forName("cn.kgc.reflect.User");
            // 获取类的包相关信息
            Package pack = clazz.getPackage();
            System.out.println("pack = " + pack);
            String name = pack.getName();
            System.out.println("name = " + name);
            // 获取类名  全限定名  cn.kgc.reflect.User
            String name1 = clazz.getName();
            System.out.println("name1 = " + name1);

            // 获取类名   User
            String simpleName = clazz.getSimpleName();
            System.out.println("simpleName = " + simpleName);

            // 获取当前类的父类
            Class superclass = clazz.getSuperclass();


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }





}
